package com.fml.easy;

import sun.security.jca.GetInstance;

public class Single {

private Single(){}

//实例用与不用都会创建  预加载
public static Single instance =new Single();
private static Single instance1;
public static Single getInstance1(){
    if (instance1 == null){
        synchronized (Single.class){
            if (instance1 == null){
                instance1 = new Single();
            }
        }
    }
    return instance1;
}



    public static class Holder{
        public Single single = new Single();
    }

    enum Singon{
        INSTANCE;
    }

    static ThreadLocal<String> threadLocal = new ThreadLocal<String>();
    public static void test(){
        threadLocal.set("2222");
    }
    public static void test1(){
        System.out.println(threadLocal.get());
    }

    public static void test2(){
        new Thread(){
            @Override
            public void run() {

                System.out.println(threadLocal.get());
            }
        }.start();
    }

    public static void main(String[] args) {
        test();
//        test1();
        test2();

    }
}
